# -*- coding:utf-8 -*-
# __author__ : "张百科"
# Date: 2021/1/26 13:55
# File: construction.py
# IDE: PyCharm

from rest_framework import serializers
from models.construction import Construction

class ConstructionSerializer(serializers.ModelSerializer):
    order_id=serializers.IntegerField(label='订单ID',help_text='订单ID',required=True)
    manager=serializers.CharField(label='项目经理',help_text='项目经理',required=True,max_length=50)
    community=serializers.CharField(label='小区',help_text='小区',max_length=50,required=True)
    room_num=serializers.CharField(label='门牌号',help_text='门牌号',max_length=50,required=False)
    owner=serializers.CharField(label='业主', max_length=50,  help_text='业主')
    layout = serializers.CharField(label='房屋布局',help_text='房屋布局',max_length=50,required=True)
    owner_tel = serializers.CharField(label='业主电话', help_text='业主电话', required=True,max_length=20)
    area = serializers.IntegerField(label='房屋面积', help_text='房屋面积', required=True)
    tel= serializers.CharField(label='项目经理电话', help_text='项目经理电话', required=True,max_length=20)
    process=serializers.IntegerField(label='当前进度', help_text='当前进度', read_only=True)
    process_display=serializers.SerializerMethodField(read_only=True)
    flow=serializers.CharField(label='整体流程', help_text='整体流程', read_only=True)
    read_count = serializers.IntegerField(read_only=True)
    create_time=serializers.DateTimeField(read_only=True)
    update_time=serializers.DateTimeField(read_only=True)
    is_done = serializers.IntegerField(read_only=True)
    is_public = serializers.IntegerField(read_only=True)
    is_typcal = serializers.IntegerField(read_only=True)

    def get_process_display(self, obj):
        return obj.get_process_display()

    class Meta:
        model = Construction
        exclude = ('is_delete',)